package com.asset.dispoal.address;

import com.asset.dispoal.address.api.AreaService;
import com.asset.dispoal.address.dto.AreaRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.protocol.Result;


@RestController
@Api(value = "地址解析配置", tags = "地址解析配置")
@RequestMapping("gb/area")
public class AreaController {

    @Autowired
    AreaService areaService;

    @PostMapping("insert")
    @ApiOperation(value = "添加地址", notes = "添加地址")
    public Result insert(@RequestBody AreaRequest request) {
        areaService.insert(request);
        return Result.ok();
    }

    @PostMapping("update")
    @ApiOperation(value = "修改地址", notes = "修改地址")
    public Result update(@RequestBody AreaRequest request) {
        areaService.update(request);
        return Result.ok();
    }

    @GetMapping("delete")
    @ApiOperation(value = "删除地址", notes = "删除地址")
    public Result delete(String id) {
        areaService.delete(id);
        return Result.ok();
    }

    @GetMapping("queryAll")
    @ApiOperation(value = "查询全部地址", notes = "查询全部地址")
    public Result queryAll() {
        return areaService.queryAll();
    }
}
